package v2.parser

import v2.parser.tree.{TypedTree,NodeCrud}

/**
 * @author bweber
 * @version $Rev$, $Date$
 */

object NodeCrudMain extends Application {
  def info(crud:NodeCrud) {
    println(crud.pwd)
    println(crud.ls)
    println(crud.current_type)
  }
  
  Type("str")
  
  val tree = TypedTree("root",Type.listTypes)
  val crud = NodeCrud(tree)
  info(crud)
  println(crud.isThereAType("str"))
  println(crud.isThereAType("person"))
  println(crud.isThereAType("person"))
  // new type
  crud.newType("craw","person") // NOT in our tree/crud
  println(crud.isThereAType("person"))
  Type(Type.typeRef("person")).attrdefs = Attr("first name",Type.typeRef("str")) :: Type(Type.typeRef("person")).attrdefs
  Type(Type.typeRef("person")).attrdefs = Attr("last name",Type.typeRef("str")) :: Type(Type.typeRef("person")).attrdefs
  info(crud)
  // new single
  println(crud.newSingle("chuck","person"))
  crud.relative_cd("chuck")
  println(crud.currentTree.currentNode)
  info(crud)
  crud.currentTree.currentNode.asInstanceOf[Single].setAttr("first name",Literal("Charles",Type.typeRef("str")))
  crud.relative_cd("first name")
  println(crud.currentTree.currentNode)

  // new bunch
  // 
}